<?php
// rename variables & fetch required data
/* @var $recipe Website_Model_Recipe */
$recipe = $this->recipe;
$photos = $recipe->getPhotos();
$videos = $recipe->getVideos();
$alternatives = $this->alternatives;
$components = $recipe->getComponents();
$gesamt = count($alternatives);
// ingredient list
foreach ( $components as /* @var $component Website_Model_Component */ $component ) {
	$ingredientList[] = $component->amount.' '.$component->unit.' '.$component->getIngredient()->name;
	$ingredientList2[] = $component->getIngredient()->name;
}
// setting meta keywords
$this->headMeta()->appendName('keywords', $recipe->name.', '.implode($ingredientList2,', ').', cocktail, rezept, cocktails, rezepte, cocktailrezepte, cocktailrezept, cocktailberater');
// setting meta description
$this->headMeta()->appendName('description', 'Das  Rezept des '.$recipe->name.' Cocktails besteht aus '.implode($ingredientList,', ').'. Mehr mit Beschreibung, Zubereitung, Fotos, Videos, Tags/Schlagworten, Kosten/Preisen, Kalorien und Kommentaren hier.');
?>
<h2><?php
print str_replace ( '\\', '', $recipe->name ) ;
if($recipe->isOriginal){
	print  ' (original)';
}
if(!$recipe->isAlcoholic()){
	print  ' (alkoholfrei)';
}
?></h2>
<img src="<?php
if(isset($photos[0]) && $photos[0]->fileName) { 
	echo $this->baseUrl() .'/img/recipes/'. $photos[ 0 ]->fileName ;
} else {
 	echo $this->baseUrl().'/img/glasses/'.$recipe->getGlass()->getPhoto()->originalFileName;
} 
?>" id="recipe_image" alt="<?php print str_replace ( '\\', '', $recipe->name ) ; ?>"
title="<?php print str_replace ( '\\', '', $recipe->name ) ; ?>"
style="margin-right: 1.6em; width: 160px; margin-top: 0.2em; margin-bottom: 20px;" />
<?php if($recipe->description){?><div class="attribut">Beschreibung:</div>
<div class="wert"><p><?php
print str_replace("\n",'</p><p>',$recipe->description);
?></p></div><?php } ?>
<div class="attribut">Zutaten:</div>
<div class="wert"><p><strong>Cocktail</strong></p>
<ul><?php
$decorations = "";
$ingredients = "";
foreach ( $components as /* @var $component Website_Model_Component */ $component ) {
	$componentString = '<li>';
	$componentString .= ''.$component->amount.'';
	$componentString .= ' ' ;
	$componentString .= ''.$component->unit.'';
	$componentString .= ' ' ;
	
	
	
	$componentString .= '<a id="zutat'.$component->getIngredient()->id.'" '.
							'href="'.$this->url(array('module'=>'website',
							'controller'=>'ingredient',
							'id'=>$component->getIngredient()->getUniqueName()),
							'ingredient',true).'?format=mobile">'.
							$component->getIngredient()->name.'</a>';
	if($component->getPreferredProduct()){
		$componentString .= '<ul style="margin-left: 1.9em;"><li>empfohlen <a href="'.$this->url(array('module'=>'website',
							'controller'=>'product',
							'id'=>$component->getPreferredProduct()->getUniqueName()),
							'produkt',true).'?format=mobile">'.$component->getPreferredProduct()->name.
							'</a>'.($component->getPreferredProduct()->getManufacturer() ? ' von <a href="'.$this->url(array('module'=>'website',
							'controller'=>'manufacturer',
							'id'=>$component->getPreferredProduct()->getManufacturer()->getUniqueName()),
							'hersteller',true).'?format=mobile">'.
							$component->getPreferredProduct()->getManufacturer()->name.'</a>' : '' ).'</li></ul>'; 
	} 
	$componentString .= '</li>';
	
	if($component->isDecoration){
		$decorations .= $componentString;
	} else {
		$ingredients .= $componentString;
	}
} // foreach

print $ingredients;

?></ul><?php 
if($decorations) { ?>
	<p class="abstand_oben"><strong>Dekoration</strong></p>
	<ul>
	<?php print $decorations; ?>
	</ul>
<?php 
} ?>
</div>
<div class="attribut">Zubereitung:</div>
<div class="wert"><p><?php
print str_replace("\n",'</p><p>',$recipe->instruction);
?></p></div>
<?php $this->headScript()->captureStart(); ?>
// sumbit the form 
var ratingFormSubmit = function(e){
    // prevent the form from actually submitting
    e.preventDefault(); 
    // submit the form in the background    
    dojo.xhrPost({
        url: "<?=$this->url(array('controller'=>'rating','action'=>'post','module'=>'website'),'rest',true)?>?format=json",
        form: "rating_form",
        handleAs: "json",
        handle: function(data,args){
            if (data.rsp["@attributes"].status == "ok"){
            	clearRatingFormError();
            	dojo.removeClass("rating_state");
            	dojo.addClass("rating_state","success");
            	dojo.byId("rating_state").innerHTML="Deine Bewertung wurde hinzugefügt.";
            }
            else if (data.rsp["@attributes"].status == "error"){
            	clearRatingFormError();
            	dojo.removeClass("rating_state");
            	dojo.addClass("rating_state","error");
            	dojo.byId("rating_state").innerHTML="Du hast schon abgestimmt!";
            }
            else {
                clearRatingFormError();
            	dojo.removeClass("rating_state");
            	dojo.addClass("rating_state","error");
            	dojo.byId("rating_state").innerHTML="Es ist ein Fehler aufgetreten. Bitte versuch es später nochmal.";
            }
        }
    });
};
dojo.addOnLoad(function(){
    var ratingForm = dojo.byId("rating_form");
    // another dojo.connect syntax: call a function directly    
    dojo.connect(ratingForm,"onsubmit",ratingFormSubmit);
});
function clearRatingFormError(){
	dojo.removeClass("rating_form")
	dojo.addClass("rating_form","hide")
}
<?php $this->headScript()->captureEnd(); ?>
<div class="attribut">Bewertung:</div>
<div class="wert"><?php $durchschnitt = $recipe->getRating(); ?>
	<p>
		<?php for($rating = 1; $rating <= 5; $rating++){ ?>
		<img id="img_rating<?php echo $rating; ?>" src="<?php print $this->baseUrl() ; ?>/img/<?php echo ($durchschnitt >= $rating) ? '1_stars.png' : 'not_yet_rated_1.png' ; ?>" height="18" width="18" alt="rating star" />
		<?php } ?>
		<span style="vertical-align: top;">(<?php print ($recipe->ratingsCount==1 ? 
			$recipe->ratingsCount.'&nbsp;Stimme' : $recipe->ratingsCount.'&nbsp;Stimmen');
			print ' - Ø&nbsp;'.number_format ( $recipe->getRating(), 2, ',', '' ) ; ?>)</span>
	</p>
<?php if($recipe->source){ ?>
<div class="attribut">Rezeptquelle:</div>
<div class="wert"><?php print $recipe->source; ?></div>
<?php } ?>	
<!-- Tags -->
<div class="attribut">Schlagworte:</div>
<div class="wert"><p><?php
$tags =  Website_Model_Tag::tagsByRecipeId($recipe->id,true);
foreach($tags as $tag){	?>
	<a href="<?php print $this->url(array('controller'=>'recipe',
	'action'=>'index'),'recipes',true); ?>?search_type=tag&amp;search=<?php 
	print $tag->getTitle(); ?>&amp;format=mobile" rel="tag" 
	id="tag<?php print str_replace(array('-',' ','.'),array('_','__','___'),$tag->getTitle()); ?>"><?php print $tag->name; ?></a>
	<?php 
}
?></p>
</div>
<div class="attribut"><a id="comments" class="nolink">Kommentare:</a></div>
<div class="wert">
	<ul id="commentList"><?php
	if (count ( $this->recipe->getComments() )) {
		$currentCommentNumber = 0;
		foreach ( $this->recipe->getComments() as $comment ) {
			$currentCommentNumber++;
			print '<li style="border-bottom: 1px solid rgb(170, 16, 97); margin-bottom: 0.5em;"'.
			($currentCommentNumber>3 ? ' class="hide"' : '').'><p><!-- #'.
				($amountOfComments--).' von --><em>' ;
			if ($comment->memberId) {
				$member = new Website_Model_Member ( $comment->memberId ) ;
				print '<a href="mailto:' . $this->escape($member->email) . '">' . $this->escape(stripslashes($member->firstname)) . ' ' . $this->escape(stripslashes($member->lastname)) . '</a>' ;
			} else if($comment->name){
				if($comment->name && $comment->email){
					print '<a href="mailto:' . $this->escape($comment->email) . '">' . $this->escape(stripslashes($comment->name)) . '</a>' ;
				} else {
					print $this->escape(stripslashes($comment->name));
				}
			} else {
				print 'anonym' ;
			}
			print '</em> schreibt: ';
			$insertDate = new Zend_Date($comment->insertDate,Zend_Date::ISO_8601);
			print ''.stripslashes(str_replace (array("\r\n", "\r", "\n",'\r\n', '\r', '\n'),
				'</p><p>',$this->escape($comment->comment))).
					' <span style="color: #888888">'.
					$insertDate->get(Zend_Date::DATETIME_SHORT,new Zend_Locale('de_DE')).
					' Uhr</span></p></li>' ;
		}
	} else {
		print '<li>keine Kommentare vorhanden</li>' ;
	}
	?></ul>
</div>
<?php if($gesamt) { ?>
<div class="attribut">Rezeptalternativen:</div>
<div class="wert"><?php
foreach ($alternatives as $alternative) { 
	$this->cocktailPreview($alternative);
} ?>
</div>
<?php } ?>
<div class="attribut" style="clear: both;">Weitere Informationen:</div>
<div class="wert">
<ul>
<li>Zubereitungszeit: <?php print $recipe->workMin; ?> min</li>
<li>Schwierigkeitsgrad: <?php
	if ($recipe->difficulty == Website_Model_Recipe::BEGINNER) {
		$difficultyMessage = 'Anfänger';
	}
	else if ($recipe->difficulty == Website_Model_Recipe::ADVANCED) {
		$difficultyMessage = 'Fortgeschritten';
	}
	else if ($recipe->difficulty == Website_Model_Recipe::PROFI) {
		$difficultyMessage = 'Profi';
	} else {
		$difficultyMessage = 'nicht eingestuft';
	}
	print $difficultyMessage; ?></li>
<li>Glas: <img
	src="<?php
	echo $this->baseUrl() .'/img/glasses/'. $recipe->getGlass()->getPhoto()->fileName ;
	?>"
	alt="Glas <?php
	print $recipe->getGlass()->name ;
	?>"
	title="Glas <?php
	print $recipe->getGlass()->name ;
	?>" /><?php
	print $recipe->getGlass()->name ;
	?></li>
	
<li>Kalorien: <?php
	if(!$caloriesComplete){
		print 'über ';
	}
	print $recipe->getCaloriesKcal(); ?> kcal</li>
<li>Alkoholgehalt: <?php
	print round($recipe->getAlcoholLevel());
	?> % Alkohol</li>
<li>Kosten: <?php
	if(!$priceComplete){
		print 'über ';
	}
	print number_format($recipe->getAveragePrice(),2,',','.');
	?> €</li>
<li>Volumen: <?php
	print $recipe->getVolumeCl() ;
	?> cl</li>
</ul>
</div>
</div><!-- END of class=left -->